<?php
    use User\Model\DailySignModel;
?>
<style>
    .table>thead>tr>th{text-align: center}
    .table>tbody>tr>td{vertical-align: middle; text-align: center}
</style>
<div id="page-wrapper">
    <div class="row">
        <div class="col-lg-12">
            <h3 class="page-header">
                <span>{$daily_sign['title']} - 用户分析</span>
            </h3>
        </div>
    </div>
    <div class="row">
        <div class="col-lg-12">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <ul class="nav nav-tabs" id="myTab">
                        <li><a href="/User/DailySign/statistics?id={$id}">总概</a></li>
                        <li class="active"><a href="javascript:;">用户行为</a></li>
                    </ul>
                </div>
                <div class="panel-body">
                    <div class="form-horizontal">
                        <div class="tab-content">
                            <div class="tab-pane active">
                                <div class="panel-body">
                                    <div class="table-responsive">
                                        <table class="table table-bordered">
                                            <thead>
                                            <tr>
                                                <th>用户id</th>
                                                <th>openid</th>
                                                <th>地区</th>
                                                <th>最新签到时间</th>
                                                <th>累计签到次数</th>
                                                <!--<th>累计积分</th>-->
                                                <th>操作</th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            <volist name="list" id="item">
                                                <tr>
                                                    <td>{$item.id}</td>
                                                    <td>{$item.openid}</td>
                                                    <td>{$item.city}</td>
                                                    <td>{$item.recent_time}</td>
                                                    <td>{$item.sign_count}</td>
                                                    <!--<td>{$item.createdate}</td>-->
                                                    <td>
                                                        <a type="button" href="javascript:;" onclick="statusUser({$item['id']}, 'delete');" class="btn btn-danger">删除</a>
                                                        <if condition="$item.status eq DailySignModel::USER_STATUS_ACTIVE">
                                                            <a type="button" href="javascript:;" onclick="statusUser({$item['id']}, 'black');" class="btn btn-primary">加入黑名单</a>
                                                        <else/>
                                                            <a type="button" href="javascript:;" onclick="statusUser({$item['id']}, 'cancel');" class="btn btn-info">取消黑名单</a>
                                                        </if>
                                                    </td>
                                                </tr>
                                            </volist>
                                            </tbody>
                                        </table>
                                    </div>
                                    <div class="pages">
                                        {$page}
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    function statusUser(id, status){
        if(status === 'delete'){
            if(!confirm('确认删除吗？')) return false;
        }else if(status === 'black'){
            if(!confirm('确认加入黑名单吗？')) return false;
        }else{
            if(!confirm('确认取消黑名单吗？')) return false;
        }
        $.ajax({
            data: {id: id,status: status},
            dataType: 'json',
            url: '/User/DailySign/statusUser',
            type: 'get',
            success: function (res) {
                alert(res['info']);
                window.location.reload();
            }
        });
        return false;
    }
</script>